<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Request;
/*
*   后台已放列表控制器
*   July  2019-03-05
*/
class Payed extends Controller
{
    //后台已放列表
    public function index(){
        return $this->fetch();
    }
    //获取数据 查询数据
    public function get_list(){
        $page = input('page');
        $limit = input('limit');
        $TrueName= input('TrueName');
        $Mobile= input('Mobile');
        $IDCard=input('IDCard');
        $timeValue=input('timeValue');
        $textValue=input('textValue');
        $searchType=input('searchType');
        $where=[];
        $where['LoanStatus']='2';
        if($TrueName)
        {
            $where['TrueName'] = $TrueName;
        }
        if($Mobile)
        {
            $where['Mobile'] = $Mobile;
        }
        if($IDCard)
        {
            $where['IDCard'] = $IDCard;
        }
        if($searchType && $searchType==1 && $timeValue)
        {
            $beginTime =substr($timeValue,0,10);
            $endTime =substr($timeValue,-10);
            $where['ApplyTime'] = ['between',[$beginTime.' 00:00:00',$endTime.' 23:59:59']];
        }
        if($searchType && $searchType==2 && $timeValue)
        {
            $beginTime =substr($timeValue,0,10);
            $endTime =substr($timeValue,-10);
            $where['OpenTime'] = ['between',[$beginTime.' 00:00:00',$endTime.' 23:59:59']];           
        }
        if($searchType && $searchType==3 && $textValue)
        {
            $where['OutTradeNo'] =$textValue; 
        }
        // if($searchType && $searchType==4 && $textValue)
        // {
        //     $where['a.OutTradeNo'] =$textValue; 
        // }
        // print_r($where);
        $data=Db::table('xb_loans_applylist')->alias('a')->field('a.ID,b.TrueName,b.Mobile,b.IDCard,a.ApplyTime,a.ApplyMoney,a.OpenTime,a.AdoptMoney,a.FkTime,c.BankName,c.BankNo,a.OutTradeNo')
        ->page($page,$limit)->order('a.ID desc')
        ->join('xb_mem_info b','a.UserID=b.ID',"LEFT")
        ->join('xb_renzen_bank c','a.UserID=c.UserID','LEFT')
        ->where($where)->select();
        $cuont=count($data);   
        if($data){
           songsong($data,$cuont);  
        }else{
            songsong();
        }
    }







}
